package haiyangwangwork.day11.homework.hk.邓仕卫;

import java.util.Scanner;

public class DoubleColor {

//    双色球的中奖程序
//    需求：
//            1). 系统产生一个双色球中奖号码
// （双色球的规则：6个红球+1个蓝球组成，红球范围：1-33，蓝色范围：1-16
//            6个红球不能重复，蓝球可以和红球的值相同）
//            2). 用户输入一组双色球号码，然后和系统产生的号码进行比较，给出比较的结果
// （中奖规则：
//    一等奖：6 + 1
//    二等奖：6 + 0
//    三等奖：5 + 1
//    四等奖：5 + 0 或 4 + 1
//    五等奖：4 + 0或 3 + 1
//    六等奖：1蓝球相符既可

    public static void main(String[] args) {

        int[] redBall = new int[6];
        int blueBall = (int) ((Math.random() * 16) + 1);
        int[] doubleColor = new int[7];
        doubleColor[6] = blueBall;
        for (int i = 0; i < redBall.length; i++) {
            redBall[i] = (int) ((Math.random() * 33) + 1);
            for (int j = 0; j < i; j++) {
                if (redBall[i] == redBall[j]) {
                    i--;
                    break;
                }
            }

        }

        for (int i = 0; i < redBall.length; i++) {
            doubleColor[i] = redBall[i];
        }

        for (int e : doubleColor) {
            System.out.print(e + " ");


        }
        System.out.println();

        Scanner input = new Scanner(System.in);

        int[] red = new int[6];
        for (int i = 0; i < red.length; i++) {
            System.out.println("请输入红球号码：");
            red[i] = input.nextInt();

        }
        System.out.println("请输入篮球号码：");
        int blue = input.nextInt();
        int[] num = new int[7];
        num[6] = blue;
        for (int i = 0; i < red.length; i++) {
            num[i] = red[i];
        }

        for (int i = 0; i < num.length; i++) {
            System.out.print(num[i] + " ");
        }

        int accountRed = 0;
        int accountBlue = 0;
        for (int i =0;i <redBall.length;i++){
            for (int j =0;j <red.length;j++){
                if (redBall[i] == red[j]){
                    accountRed++;
                }
            }
        }

        if (blueBall == blue) accountBlue = 1;

        String result = "";
        if (accountRed ==6 && accountBlue ==1){
            result = "一等奖";
        } else if (accountRed ==6 && accountBlue ==0) {
            result = "二等奖";
        } else if (accountRed ==5 && accountBlue ==1) {
            result = "三等奖";
        } else if (accountRed ==5 || (accountRed ==4 && accountBlue ==1)) {
            result = "四等奖";
        } else if (accountRed ==4 ||( accountRed ==3 && accountBlue ==1)) {
            result ="五等奖";
        } else if (accountBlue ==1) {
            result = "六等奖";
        }else result = "未中奖";

        System.out.println("恭喜你，中了" +result);
    }


}
